package com.jltx.xq.zeus.startup.dispatcher

import com.jltx.xq.zeus.startup.Startup

/**
 * @author aidenquan
 *         Created by junlintianxia on 2022/07/14.
 */
interface StartupDispatcher {
    /**
     * 返回是否在主线程执行
     */
    fun callCreateOnMainThread(): Boolean

    /**
     * 是否需要主线程等待该任务执行完成
     * callCreateOnMainThread()方法返回false才有意义
     */
    fun waitOnMainThread(): Boolean

    /**
     * To wait dependencies startup completed.
     * 等待依赖的任务
     */
    fun toWait()

    /**
     * To notify the startup when dependencies startup completed.
     * 有父任务执行完毕
     * 计数器-1
     */
    fun toNotify()

    /**
     * Called whenever there is a dependency completion.
     *
     * @param [startup] dependencies [startup].
     * @param [result] of dependencies startup.
     */
    fun onDependenciesCompleted(startup: Startup<*>, result: Any?)

    /**
     * 指定线程的优先级
     */
    fun getThreadPriority(): Int
}